package top.dprkshow.practice.binarySearch;

/**
 * @author Kent HAN
 * @date 2021/8/16
 */
public class BinarySearch {
    public int binarySearch(int[] arr, int start, int end, int target) {
        int mid = (start + end) / 2;
        if (arr[mid] == target) {
            return mid;
        }
        if (end < start) {
            return -1;
        } else if (arr[mid] > target) {
            end = mid - 1;
            return binarySearch(arr, start, end, target);
        } else {
            start = mid + 1;
            return binarySearch(arr, start, end, target);
        }
    }
}
